import { reqGetSearchInfo } from "../api/search";

export default {
  namespaced: true,
  state: {
    //home仓库中存储三级菜单的数据
    searchList: {},
  },
  mutations: {
    GETSEARCHLIST(state, searchList) {
      state.searchList = searchList;
    },
  },
  actions: {
    async getSearchList({ commit }, params = {}) {
      //reqgetCategoryList返回的是一个Promise对象
      //需要用await接受成功返回的结果，await必须要结合async一起使用（CP）
      let result = await reqGetSearchInfo(params);
      if (result.code == 200) {
        commit("GETSEARCHLIST", result.data);
      }
    },
  },
  getters: {
    goodsList(state) {
      return state.searchList.goodsList || [];
    },
    trademarkList(state) {
      return state.searchList.trademarkList || [];
    },
    attrsList(state) {
      return state.searchList.attrsList || [];
    },
    total (state){
      return state.searchList.total
    } 
  },
};
